#ifndef EXIT_FEATURE_H
#define EXIT_FEATURE_H

#include "feature.h"
#include "../widgets/checkbox.h"
#include "../widgets/button.h"

#include <QApplication>

class ExitFeature: public Feature, public ButtonListener
{
public:
    ExitFeature(int _id, Engine* _engine, int _x, int _y, int _w, int _h, ControllerProxy* _cProxy, MainWidget* _mw)
        :Feature(_id, _engine, _mw, _cProxy, _x, _y, _w, _h)
    {
        sure = new Label(this, engine, "Sure?", 0, 0, 150, 30, Label::Center);
        sure->SetX((w - 150) / 2);
        sure->SetY(h/3);

        yes = new Button(this, engine, "Yes", 0, 0, 60, 25);
        yes->SetX(sure->GetX());
        yes->SetY(sure->GetY() + 40);
        yes->AddButtonListener(this);

        no = new Button(this, engine, "No", 0, 0, 60, 25);
        no->SetX(sure->GetX() + sure->GetWidth() - 60);
        no->SetY(yes->GetY());
        no->AddButtonListener(this);

        AddChild(sure);
        AddChild(yes);
        AddChild(no);
    }

    virtual ~ExitFeature(){ }

    virtual void OnClick(Button *b, QMouseEvent *e, int rel_x, int rel_y)
    {
        if(b->GetText() == "Yes")
        {
            QApplication::exit();
        }
    }


private:
    Label* sure;
    Button* yes;
    Button* no;
    CheckBox* choice;
};

#endif // EXIT_FEATURE_H
